import { CallSprite } from "./CallSprite";
import { ResouceConst } from "../../../../component/gconst/ResouceConst";
import { GButton } from "../../../../../com/mui/controls/GButton";
import { FilterConst } from "../../../../component/gconst/FilterConst";
import { GlobalClass } from "../../../../../com/mui/core/GlobalClass";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../events/DataEvent";
import { EventName } from "../../../mvc/EventName";
type int = number;
//class ShieldTypePanel
    
    export  class ShieldTypePanel extends CallSprite
    {
        constructor(arg1: Array<any>)
        {
            super();
            this._dicBtnShieldObj = new Map<any, any> /* flash.utils.Dictionary */();
            this._dataArray = arg1;
            var loc1=0;
            while (loc1 < this._dataArray.length) 
            {
                (this._dataArray[loc1] as Object).isShield = false;
                ++loc1;
            }
            this.createChildren();
            return;
        }

        /* internal  */createChildren(): void
        {
            var loc1=ResouceConst.getScaleBitmap("ToolTipBg");
            loc1.width = 72;
            loc1.height = this._dataArray.length * 25 + 10;
            this.addChild(loc1);
            var loc2=0;
            while (loc2 < this._dataArray.length) 
            {
                this.createButton(loc2, this._dataArray[loc2]);
                ++loc2;
            }
            return;
        }

        /* internal  */createButton(arg1: int, arg2: Object): void
        {
            var loc1=null;
            var loc2=null;
            loc1 = new GButton();
            loc1.x = 6;
            loc1.y = arg1 * 25 + 5;
            loc1.width = 60;
            loc1.height = 24;
            loc1.styleName = "ButtonMini";
            loc1.name = arg2["name"];
            loc1.label = arg2["label"];
            loc1.textField.filters = [FilterConst.glowFilter];
            loc1.addEventListener(flash.events.MouseEvent.CLICK, this.btnClickHandler);
            this.addChild(loc1);
            (loc2 = GlobalClass.getBitmap("Gag")).x = 6;
            loc2.y = 5;
            loc2.width = 14;
            loc2.height = 14;
            loc2.visible = false;
            loc1.addChild(loc2);
            this._dicBtnShieldObj[loc1] = loc2;
            return;
        }

        /* internal  */btnClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            var loc1=this.getObjByName((arg1.target as GButton).name);
            if (loc1) 
            {
                if (loc1["isShield"]) 
                {
                    loc1["isShield"] = false;
                    (this._dicBtnShieldObj[arg1.target] as Object /* flash.display.DisplayObject */).visible = false;
                    (arg1.target as GButton).label = loc1["label"];
                }
                else 
                {
                    loc1["isShield"] = true;
                    (this._dicBtnShieldObj[arg1.target] as Object /* flash.display.DisplayObject */).visible = true;
                    (arg1.target as GButton).label = "    " + loc1["label"];
                }
                Dispatcher.dispatchEvent(new DataEvent(EventName.ChatShield, {"label": loc1["label"], "isShield": loc1["isShield"]}));
            }
            return;
        }

        public getNotShieldNameList(): Array<any>
        {
            var loc2=null;
            var loc1=new Array<any>();
            var loc3=0;
            var loc4=this._dataArray;
            for(loc2 of loc4) 
            {
                if (loc2["isShield"]) 
                {
                    continue;
                }
                loc1.push(loc2["name"]);
            }
            return loc1;
        }

        /* internal  */getObjByName(arg1: string): Object
        {
            var loc1=null;
            var loc2=0;
            var loc3=this._dataArray;
            for(loc1 of loc3) 
            {
                if (!(loc1.hasOwnProperty("name") && loc1["name"] == arg1)) 
                {
                    continue;
                }
                return loc1;
            }
            return null;
        }

        /* internal */ /* var */_dataArray: Array<any>;

        /* internal */ /* var */_dicBtnShieldObj: Map<any, any> /* flash.utils.Dictionary */;
    }
